<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>openGauss Blog  | openGauss社区入门（git使用基础）</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    <link rel="shortcut icon" href="https://xzx666.gitee.io/lookeng/img/favicon.ico" type="image/x-icon" />
    <link rel="apple-touch-icon" href="https://xzx666.gitee.io/lookeng/img/apple-touch-icon.png" />

    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/commen.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/blog.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/mobile.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/pagination.css?t=1607593672000">
    
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?34e9f585f29581007941aa1698181871";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
</head>
<body>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>






<div class="container">
    <div class="columns blog-detail">
        <div class="post_detail">
            <div class="is-child box">
                <div class="breadCrumb"><a href="\zh\">博客/</a></div>
                <div class="blog-detail-header">
                    <h1>openGauss社区入门（git使用基础）</h1>
                    <div class="blog-detail-prop">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-date.png">
                        <span class="article_right_date">2020-05-30</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-author.png">
                        <span class="article_right_author">xingchen</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-view.png">
                        <span id="/zh/post/xingchen/2020-05-30-start1/" class="leancloud_visitors" data-flag-title="openGauss社区入门（git使用基础）">
                            <i class="leancloud-visitors-count"></i>                     
                        </span>
                    </div>
                    <div class="blog-detail-tags">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-tag.png">
                        
                        <a href="https://xzx666.gitee.io/lookeng/zh/tags/opengauss%E7%A4%BE%E5%8C%BA%E5%BC%80%E5%8F%91%E5%85%A5%E9%97%A8">openGauss社区开发入门</a>
                        
                    </div>
                </div>
                <div class="content blog-content">
                    

<h3 id="前言">前言</h3>

<p>这两天参与了社区建设的一些事情，总结下用到的一些基本的操作放到blog里面供大家参考，有不对的地方还望指正。</p>

<p>Git基本使用</p>

<h3 id="git安装和配置">Git安装和配置</h3>

<hr />

<ol>
<li>Git下载</li>
</ol>

<p>可以到git官网下载git客户端，<a href="https://git-scm.com/downloads">git下载地址</a>。里面附有各个操作系统下详细的安装命令，按照命令安装即可。</p>

<ol>
<li>配置用户和邮箱</li>
</ol>

<p>window下打开gitbash窗口，设置用户名和邮箱。</p>

<pre><code>git config --global user.name &lt;username&gt;
git config --global user.email &lt;useremail&gt;
</code></pre>

<p>配置完成后，通过 <code>git config --list</code> 查看
<img src="../images/configlist.png" alt="" /></p>

<ol>
<li>生成SSH公钥</li>
</ol>

<p>gitbash窗口输入命令：</p>

<pre><code>ssh-keygen -t rsa -C &lt;useremail&gt;
</code></pre>

<p>按照提示按三次回车，生成ssh公钥。
gitbash窗口使用如下命令查看生成的ssh公钥：</p>

<pre><code>cat ~/.ssh/id_rsa.pub 
</code></pre>

<p>复制公钥，并在gitee网站导入公钥。
<img src="../images/catssh.png" alt="" /></p>

<ol>
<li>导入SSH公钥</li>
</ol>

<p>登录到gitee网站，进入<strong>个人-设置-SSH公钥</strong>，复制公钥并粘贴到界面上公钥的文本框里面，点击确定按钮来添加公钥。
<img src="../images/sshkey.png" alt="" /></p>

<p>至此，git配置完成，可以下载开发以及提交代码了。</p>

<h3 id="下载与提交代码">下载与提交代码</h3>

<hr />

<p>以opengauss/website工程为例，进行一次修改提交。</p>

<ol>
<li>Fork仓库</li>
</ol>

<p>普遍的流程，开发者先从主干仓库Fork出个人仓库，基于个人仓库进行开发。完成后提交代码到自己的仓库里面，再从自己仓库提交Pull Request到主干仓库。</p>

<p>opengauss/website工程下面点击Fork按钮，Fork到自己的仓库里面。
<img src="../images/fork.png" alt="" /></p>

<ol>
<li>下载代码</li>
</ol>

<p>复制需要下载的工程地址，在gitbash上使用<code>git clone</code>命令下载代码</p>

<pre><code>git clone &lt;git_https_url&gt;
</code></pre>

<p><img src="../images/gitclone.png" alt="" /></p>

<p>git clone命令可以添加参数：</p>

<pre><code>git clone &lt;git_https_url&gt; -b &lt;branch&gt; &lt;projectName&gt;
</code></pre>

<p><code>git clone</code>默认下载master分支代码，命令中添加<code>-b branch</code>参数即可下载指定分支代码。
<code>&lt;projectName&gt;</code>参数不添加是工程默认名称，添加后会把下载到本地的文件夹名称改为指定名称。</p>

<ol>
<li>提交代码</li>
</ol>

<p>本次我们在website工程中添加一个test.txt文件。</p>

<pre><code class="language-git">
![](../images/gitstatus.png)

</code></pre>

<p>git add .```  &ndash; 将所有修改的文件添加到git的缓存区</p>

<p><img src="../images/gitadd.png" alt="" /></p>

<pre><code class="language-git">
</code></pre>

<p>git push origin master``` &ndash; 提交修改到自己的仓库里面</p>

<ol>
<li>提Pull Request</li>
</ol>

<p>合入到自己的仓库后，在页面创建<strong>Pull Request</strong>，提交PR到主干仓库</p>

<p><img src="../images/pr1.png" alt="" />
<img src="../images/pr2.png" alt="" /></p>

                </div>
            </div>
            <div class="box" style="margin-top:15px;">
                <div style="font-size:14px;color:gray"><strong>【免责声明】</strong>本文仅代表作者本人观点，与本网站无关。本网站对文中陈述、观点判断保持中立，不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。本文仅供读者参考，由此产生的所有法律责任均由读者本人承担。</div>
            </div>
            <div class="post-comment">
                
                  
  <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/custom.css" />
  <div id="vcomments" lang="zh-cn" mess="说点什么吧..."></div>

  <script type="text/javascript">
    const placeholder = document.getElementById("vcomments").getAttribute("mess"),
          lang = document.getElementById("vcomments").getAttribute("lang");
    const  langs = lang == "zh-cn" ? "zh-cn" : "en";
    new Valine({
        el: '#vcomments' ,
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm', 
        placeholder: placeholder,
        visitor: true,
		    meta: ['nick','mail','link'],
        lang: langs
    });
  </script>
            </div>
        </div>
    </div>
</div>
<script>
    $(function (){
        var query = new AV.Query('Counter');
        query.equalTo('url', decodeURIComponent('\/zh\/post\/xingchen\/2020-05-30-start1\/'));
        query.find().then(function (data) {
            if(data.length && (data[0].attributes.author === 'openGauss')){
                var counter = AV.Object.createWithoutData('Counter', data[0].id);
                counter.set('author', 'xingchen');
                counter.save();
            }
        })
    })
</script>







<input id="iframeUrl" type="text" style="display: none;" value=https://xzx666.gitee.io/>




<script defer src="https://xzx666.gitee.io/lookengjs/all.js"></script>
<script src="https://xzx666.gitee.io/lookengjs/flexible.js"></script>
<script>
  const hash = window.location.search,
        pageurl = window.location.href;
  var langss = document.querySelector("html").lang === "zh-cn" ? "zh" : "en";
  console.log("hash:",hash,"pageurl:",pageurl,"ttr",pageurl.split(langss + "/")[1])

  if(!document.getElementById("vcomments")) {
    new Valine({
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm',
        visitor: true,
		    meta: ['nick','mail','link']
    });
  }
 
  
    


    const url = document.getElementById("iframeUrl").value;

    function observe (el, options, callback) {
      var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
      var observer = new MutationObserver(callback)
      observer.observe(el, options)
    }

    var options = {
        childList: true,
        subtree: true,
        characterData: true
      }
    observe(document.body, options, (records, instance) => {
    const height = document.body.scrollHeight;
    parent.postMessage(height,url);
    })
    if(pageurl.split(langss + "/")[1]) parent.postMessage(pageurl.split(langss + "/")[1],url);
    

    if(document.querySelector("#notFound")) parent.postMessage("我404了",url);

</script>
</body>
</html>
